home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / utility / col_dos.zip / COLOR.PAS < prev   
Pascal/Delphi Source File  |  1996-06-03  |  8KB  |  234 lines

  1. program Color_Cursors;
  2.  
  3. {$N-,E-,Q-,S-,R+,I-,O-,F-,P+,T-,X-,V-,B-,A+,G-,D-,L-,Y-}
  4. {$M 1024,0,0}
  5.  
  6. (* compiled in Borland Turbo Pascal 7.0 for DOS *)
  7.  
  8. uses crt;
  9.  
  10. label Start;
  11.  
  12. var
  13. Background,Foreground : shortint;
  14. Choice : char;
  15.  
  16. procedure Usage;
  17.  
  18. begin
  19. textcolor(7);
  20. textbackground(0);
  21. write('                                                                                ');
  22. if paramstr(1) <> '?' then write(' Wrong input, man.                                                              ');
  23. write('                                                                                ');
  24. write(' Usage:   Color B F                                                             ');
  25. write('          where B is for background and is a whole number from 0 thru 7,        ');
  26. write('          and F is for foreground and is a whole number from 0 thru 15.         ');
  27. write('          The two numbers cannot match.                                         ');
  28. write('                                                                                ');
  29.  
  30. if paramstr(1) <> '?' then
  31. begin
  32. write('          To get this screen for help at anytime without comment, Enter         ');
  33. write('          this:  Color ?  from the DOS prompt.                                  ');
  34. write('                                                                                ');
  35. end;
  36.  
  37. write(' Example: Color 1 14                                                            ');
  38. write('                                                                                ');
  39. write(' This program changes the background and foreground colors of DOS from the      ');
  40. write(' command-line. Not a Tsr. Especially good for use in batch files, to set        ');
  41. write(' the colors upon return to DOS. Below are the color codings:                    ');
  42. textcolor(1);
  43. write(' 1');
  44. textcolor(2);
  45. write(' 2');
  46. textcolor(3);
  47. write(' 3');
  48. textcolor(4);
  49. write(' 4');
  50. textcolor(5);
  51. write(' 5');
  52. textcolor(6);
  53. write(' 6');
  54. textcolor(7);
  55. write(' 7');
  56. textcolor(8);
  57. write(' 8');
  58. textcolor(9);
  59. write(' 9');
  60. textcolor(10);
  61. write(' 10');
  62. textcolor(11);
  63. write(' 11');
  64. textcolor(12);
  65. write(' 12');
  66. textcolor(13);
  67. write(' 13');
  68. textcolor(14);
  69. write(' 14');
  70. textcolor(15);
  71. write(' 15                                            ');
  72. textcolor(7);
  73. write(' The first one, 0 for black, doesn''t show, but it works too. Finally, for       ');
  74. write(' this program to work, to change the colors of DOS, you can''t run any kind      ');
  75. write(' of ANSI device driver from Config.sys. Check Config.sys for something like     ');
  76. write(' Device=Ansi.Sys, etc. Remove the line if you can.                              ');
  77. write('                                                                                ');
  78. halt;
  79. end;  (* ends help screen, parameters can only be  ?  or wrong *)
  80.  
  81. procedure Exit_to_DOS;
  82.  
  83. begin
  84. textbackground(Background);
  85. textcolor(Foreground);
  86. clrscr;
  87. writeln;
  88. writeln;
  89. writeln(' If it didn''t work, you''re probably using an ANSI device driver.');
  90. writeln;
  91. writeln(' If you want a normal DOS screen back, enter the DOS command CLS.');
  92. writeln;
  93. writeln(' You entered ',BackGround,' for background and ',ForeGround,' for foreground.');
  94. writeln;
  95. halt;
  96. end;
  97.  
  98. begin  (* Main *)  
  99. if paramcount = 0 then begin textbackground(0); textcolor(7); goto Start; end;
  100.  
  101. if paramcount <> 2 then Usage; (* Help screen in procedure Usage, *)                           
  102.                                (* Begin the command-line version *)
  103.                                
  104. if paramstr(1) = '0' then Background := 0
  105. else if paramstr(1) = '1' then Background := 1
  106. else if paramstr(1) = '2' then Background := 2
  107. else if paramstr(1) = '3' then Background := 3
  108. else if paramstr(1) = '4' then Background := 4
  109. else if paramstr(1) = '5' then Background := 5
  110. else if paramstr(1) = '6' then Background := 6
  111. else if paramstr(1) = '7' then Background := 7
  112. else Usage;
  113.  
  114. if paramstr(2) = '0' then Foreground := 0
  115. else if paramstr(2) = '1' then Foreground := 1
  116. else if paramstr(2) = '2' then Foreground := 2
  117. else if paramstr(2) = '3' then Foreground := 3
  118. else if paramstr(2) = '4' then Foreground := 4
  119. else if paramstr(2) = '5' then Foreground := 5
  120. else if paramstr(2) = '6' then Foreground := 6
  121. else if paramstr(2) = '7' then Foreground := 7
  122. else if paramstr(2) = '8' then Foreground := 8
  123. else if paramstr(2) = '9' then Foreground := 9
  124. else if paramstr(2) = '10' then Foreground := 10
  125. else if paramstr(2) = '11' then Foreground := 11
  126. else if paramstr(2) = '12' then Foreground := 12
  127. else if paramstr(2) = '13' then Foreground := 13
  128. else if paramstr(2) = '14' then Foreground := 14
  129. else if paramstr(2) = '15' then Foreground := 15
  130. else Usage;
  131.  
  132. if Background = Foreground then Usage;
  133.  
  134. textbackground(BackGround);
  135. textcolor(ForeGround);
  136. clrscr;
  137. exit;  (* Successful parameters, exit to Dos with new colors from command line *)
  138.  
  139. (* Begin the menu-driven part of the program *)
  140. Start:
  141. clrscr;
  142. writeln;
  143. writeln('This program changes the color of DOS and some of its command-line programs,');
  144. writeln('such as DIR, PkZip, MEM/C, LIST, etc. However, for ColorDos to work, you can''t');
  145. writeln('run Ansi.Sys or any other type of ANSI driver from the Config.Sys boot-up file.');
  146. writeln('Check Config.Sys for a line such as Device=Ansi.Sys, or Device=Zansi.Sys, etc.');
  147. writeln('Remove it if you can. Below are your choices on background and foreground. To');
  148. writeln('return to a default, text mode DOS screen, you just put the command CLS. Also,');
  149. writeln('many programs destroy the colors, and you''ll want to run Color with parameters.');
  150. writeln('You will get two prompts, the first one is to choose background. The 2nd one is');
  151. writeln('to choose foreground. The backgrounds are 0 thru 7, with 0 being black. The');
  152. writeln('foregrounds are 0 thru 15. All colors except black are shown below. You can''t');
  153. writeln('enter the same number for background and foreground (obviously). Then you may');
  154. writeln('view a sample, or exit to DOS in your choice of colors. From the sample you may');
  155. writeln('exit to DOS in your colors, or return to the menu to try others. Here they are:');
  156. textcolor(1);
  157. write('1 ');
  158. textcolor(2);
  159. write('2 ');
  160. textcolor(3);
  161. write('3 ');
  162. textcolor(4);
  163. write('4 ');
  164. textcolor(5);
  165. write('5 ');
  166. textcolor(6);
  167. write('6 ');
  168. textcolor(7);
  169. write('7 ');
  170. textcolor(8);
  171. write('8 ');
  172. textcolor(9);
  173. write('9 ');
  174. textcolor(10);
  175. write('10 ');
  176. textcolor(11);
  177. write('11 ');
  178. textcolor(12);
  179. write('12 ');
  180. textcolor(13);
  181. write('13 ');
  182. textcolor(14);
  183. write('14 ');
  184. textcolor(15);
  185. write('15');
  186. textcolor(7);
  187. writeln('  (the first one, 0 black, doesn''t show).');
  188. writeln('Help is avalaible for using Color quicker on the command-line, Enter this at');
  189. writeln('the DOS Prompt:  Color ?  To exit now in these colors, hit Ctrl-Break.');
  190. reset(input);
  191. writeln;
  192. write('Enter Background:  (0-7) ────> ');
  193. if not eoln(input) then
  194. read(BackGround) else goto Start;
  195. if ioresult = 106 then goto Start;
  196. if (Background < 0) or (Background > 7) then goto Start;
  197.  
  198. reset(input);
  199. write('Enter Foreground: (0-15) ────> ');
  200. if not eoln(input) then
  201. read(ForeGround)
  202. else goto Start;
  203. if ioresult = 106 then goto Start;
  204. if (Foreground < 0) or (Foreground > 15) then goto Start;
  205. if Foreground = Background then goto Start;
  206.  
  207. writeln;
  208. write('View a sample? (Y/N) ');
  209. Choice := readkey;
  210. case Choice of
  211. 'y','Y' :
  212. begin
  213. writeln;
  214. textbackground(Background);
  215. textcolor(Foreground);
  216. writeln;
  217. write(' SAMPLE TEXT ');
  218. textcolor(7);
  219. textbackground(0);
  220. write('  Return to DOS with these colors? (Y/N) ');
  221. Choice := readkey;
  222.  
  223. case Choice of
  224. 'y','Y' : Exit_to_DOS;
  225. 'n','N' : goto Start;
  226. else begin write(' ....wrong key....'); writeln; exit; end;
  227. end;
  228. end; (* Ends 2nd case statement *)
  229.  
  230. 'n','N' : Exit_to_DOS;
  231. else goto Start;
  232. end; (* Ends 1st case statement *)
  233.  
  234. end.